
var {
    serverStatus,
} = require('./config');

const healthCheck = (pools) => {
    const res = {}
    Object.keys(pools).forEach(key => {
        const value = pools[key];
        if (value.status === serverStatus.online){
            res[key] = value;
        }else{
            console.log(`server ${key} does not work`);
        }
    })
    return res;
}

const intevalCheck = (cb) => {
    setInterval(() => {
        console.log('inteval health check')
        cb && cb()
    }, 1000)
}

module.exports = {
    healthCheck,
    intevalCheck
}